<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="tool," />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.0" />






<meta name="description" content="泛化 （Generalization）类图 关系 表示一种继承关系。子类继承父类所有的特性与方法。当然子类可以覆盖父类中的方法。 箭头指向被继承的父类，实线  实现 （Implements）类图 关系 表示类与接口的关系。实现类实现接口中约定的规范。 箭头指向接口，并且是虚线  代码体现组合（Composition）类图 关系 关联关系的一种。表示一种整体和部分的关系，并且是一种强关系（较之聚合）">
<meta name="keywords" content="tool">
<meta property="og:type" content="article">
<meta property="og:title" content="UML类图">
<meta property="og:url" content="https://gitee.com/shuhao/2018/09/27/UML类图/index.html">
<meta property="og:site_name" content="Niki">
<meta property="og:description" content="泛化 （Generalization）类图 关系 表示一种继承关系。子类继承父类所有的特性与方法。当然子类可以覆盖父类中的方法。 箭头指向被继承的父类，实线  实现 （Implements）类图 关系 表示类与接口的关系。实现类实现接口中约定的规范。 箭头指向接口，并且是虚线  代码体现组合（Composition）类图 关系 关联关系的一种。表示一种整体和部分的关系，并且是一种强关系（较之聚合）">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_generalization.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_implements.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_composition.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_aggregation.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_association.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class_dependency.jpg">
<meta property="og:image" content="https://gitee.com/blog/images/tool/uml/uml_class.png">
<meta property="og:updated_time" content="2018-09-27T09:50:10.548Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="UML类图">
<meta name="twitter:description" content="泛化 （Generalization）类图 关系 表示一种继承关系。子类继承父类所有的特性与方法。当然子类可以覆盖父类中的方法。 箭头指向被继承的父类，实线  实现 （Implements）类图 关系 表示类与接口的关系。实现类实现接口中约定的规范。 箭头指向接口，并且是虚线  代码体现组合（Composition）类图 关系 关联关系的一种。表示一种整体和部分的关系，并且是一种强关系（较之聚合）">
<meta name="twitter:image" content="https://gitee.com/blog/images/tool/uml/uml_class_generalization.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/shuhao/2018/09/27/UML类图/"/>





  <title> UML类图 | Niki </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?cb9f0585e406f878cb2f29c89ad3cdb7";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Niki</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">天道酬勤</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-categories"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/shuhao/blog/2018/09/27/UML类图/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Fang ShuHao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/head.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Niki">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                UML类图
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-09-27T16:52:43+08:00">
                2018-09-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/tool/" itemprop="url" rel="index">
                    <span itemprop="name">tool</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="泛化-（Generalization）"><a href="#泛化-（Generalization）" class="headerlink" title="泛化 （Generalization）"></a>泛化 （Generalization）</h1><h2 id="类图"><a href="#类图" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_generalization.jpg">
<h2 id="关系"><a href="#关系" class="headerlink" title="关系"></a>关系</h2><ul>
<li>表示一种继承关系。子类继承父类所有的特性与方法。当然子类可以覆盖父类中的方法。</li>
<li>箭头指向被继承的父类，实线</li>
</ul>
<h1 id="实现-（Implements）"><a href="#实现-（Implements）" class="headerlink" title="实现 （Implements）"></a>实现 （Implements）</h1><h2 id="类图-1"><a href="#类图-1" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_implements.jpg">
<h2 id="关系-1"><a href="#关系-1" class="headerlink" title="关系"></a>关系</h2><ul>
<li>表示类与接口的关系。实现类实现接口中约定的规范。</li>
<li>箭头指向接口，并且是虚线</li>
</ul>
<h2 id="代码体现"><a href="#代码体现" class="headerlink" title="代码体现"></a>代码体现</h2><h1 id="组合（Composition）"><a href="#组合（Composition）" class="headerlink" title="组合（Composition）"></a>组合（Composition）</h1><h2 id="类图-2"><a href="#类图-2" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_composition.jpg">
<h2 id="关系-2"><a href="#关系-2" class="headerlink" title="关系"></a>关系</h2><ul>
<li>关联关系的一种。表示一种整体和部分的关系，并且是一种强关系（较之聚合），整体对象代表负责部分对象的生命周期。也就是说部分脱离了整体则无法存在。如同公司下的部门，如果公司不存在，则下面的部门则没有意义。</li>
<li>实心菱形指向整体，箭头指向部分，并且为实线。可以通过数字表示整体与部分之间的数量关系。大部分为 1个整体，多个部分。</li>
</ul>
<h2 id="代码体现-1"><a href="#代码体现-1" class="headerlink" title="代码体现"></a>代码体现</h2><p>在代码中的体现为：类用户成员变量的关系</p>
<h1 id="聚合（Aggregation）"><a href="#聚合（Aggregation）" class="headerlink" title="聚合（Aggregation）"></a>聚合（Aggregation）</h1><h2 id="类图-3"><a href="#类图-3" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_aggregation.jpg">
<h2 id="关系-3"><a href="#关系-3" class="headerlink" title="关系"></a>关系</h2><ul>
<li>也是关联关系的一种，但是是一种弱关联。整体对象并不能代表部分对象的生命周期。类似于乐高玩具组成的汽车与零件的关系。可以将汽车拆开，则汽车不存在，但是拆下来的轮子，引擎等零件可以另外组装成其他汽车。</li>
<li>空心菱形指向整体，箭头指向部分，实线。<h2 id="代码体现-2"><a href="#代码体现-2" class="headerlink" title="代码体现"></a>代码体现</h2>在代码中的体现为：类与成员变量</li>
</ul>
<h1 id="关联（Association）"><a href="#关联（Association）" class="headerlink" title="关联（Association）"></a>关联（Association）</h1><h2 id="类图-4"><a href="#类图-4" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_association.jpg">
<h2 id="关系-4"><a href="#关系-4" class="headerlink" title="关系"></a>关系</h2><ul>
<li>表示两个对象间的拥有关系。如一对多，一对一，多对多</li>
<li>箭头指向多的一方，多对多可以都不用箭头。</li>
</ul>
<h2 id="代码体现-3"><a href="#代码体现-3" class="headerlink" title="代码体现"></a>代码体现</h2><p>在代码中也可通过成员变量体现</p>
<h1 id="依赖（Dependency）"><a href="#依赖（Dependency）" class="headerlink" title="依赖（Dependency）"></a>依赖（Dependency）</h1><h2 id="类图-5"><a href="#类图-5" class="headerlink" title="类图"></a>类图</h2><img src="/blog/images/tool/uml/uml_class_dependency.jpg">
<h2 id="关系-5"><a href="#关系-5" class="headerlink" title="关系"></a>关系</h2><ul>
<li>表示一种使用关系。一个类需要另一个类的协助</li>
<li>带箭头的虚线。箭头指向被需要对象</li>
</ul>
<h2 id="代码体现-4"><a href="#代码体现-4" class="headerlink" title="代码体现"></a>代码体现</h2><p>在代码中，体现为局部变量，方法参数，静态方法调用。所以不建议在代码中存在互相依赖的关系。</p>
<p>各个关系的强弱顺序为<br>泛化 = 实现 &gt; 组合 &gt; 聚合 &gt; 关联 &gt; 依赖</p>
<p>下面放一张比较形象的类图：<br><img src="/blog/images/tool/uml/uml_class.png"></p>
<blockquote>
<blockquote>
<p>参考<br><a href="http://www.uml.org.cn/oobject/201609062.asp" target="_blank" rel="external">uml类图关系总结</a></p>
</blockquote>
</blockquote>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/tool/" rel="tag"># tool</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/09/25/Spring三种扩展机制/" rel="next" title="Spring三种扩展机制">
                <i class="fa fa-chevron-left"></i> Spring三种扩展机制
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/11/07/springboot创建Web项目/" rel="prev" title="springboot创建Web项目">
                springboot创建Web项目 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zNjY5NS8xMzIzMA=="></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/blog/images/head.jpg"
               alt="Fang ShuHao" />
          <p class="site-author-name" itemprop="name">Fang ShuHao</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/blog/archives">
                <span class="site-state-item-count">135</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories">
                <span class="site-state-item-count">35</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/blog/tags">
                <span class="site-state-item-count">93</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#泛化-（Generalization）"><span class="nav-number">1.</span> <span class="nav-text">泛化 （Generalization）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图"><span class="nav-number">1.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系"><span class="nav-number">1.2.</span> <span class="nav-text">关系</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#实现-（Implements）"><span class="nav-number">2.</span> <span class="nav-text">实现 （Implements）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图-1"><span class="nav-number">2.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系-1"><span class="nav-number">2.2.</span> <span class="nav-text">关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码体现"><span class="nav-number">2.3.</span> <span class="nav-text">代码体现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#组合（Composition）"><span class="nav-number">3.</span> <span class="nav-text">组合（Composition）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图-2"><span class="nav-number">3.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系-2"><span class="nav-number">3.2.</span> <span class="nav-text">关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码体现-1"><span class="nav-number">3.3.</span> <span class="nav-text">代码体现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#聚合（Aggregation）"><span class="nav-number">4.</span> <span class="nav-text">聚合（Aggregation）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图-3"><span class="nav-number">4.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系-3"><span class="nav-number">4.2.</span> <span class="nav-text">关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码体现-2"><span class="nav-number">4.3.</span> <span class="nav-text">代码体现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#关联（Association）"><span class="nav-number">5.</span> <span class="nav-text">关联（Association）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图-4"><span class="nav-number">5.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系-4"><span class="nav-number">5.2.</span> <span class="nav-text">关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码体现-3"><span class="nav-number">5.3.</span> <span class="nav-text">代码体现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#依赖（Dependency）"><span class="nav-number">6.</span> <span class="nav-text">依赖（Dependency）</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#类图-5"><span class="nav-number">6.1.</span> <span class="nav-text">类图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关系-5"><span class="nav-number">6.2.</span> <span class="nav-text">关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码体现-4"><span class="nav-number">6.3.</span> <span class="nav-text">代码体现</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Fang ShuHao</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  



  
  

  

  

  

  


  

</body>
</html>
